<?php

use Phinx\Migration\AbstractMigration;

class CreateBlackCardSub extends AbstractMigration
{
    public function change()
    {
        $table = $this->table('black_card_sub');
        $table->addColumn('main_id', 'integer', ['comment' => '主卡ID'])
            ->addColumn('card_no', 'string', ['limit' => 50, 'comment' => '卡号'])
            ->addColumn('balance', 'decimal', ['precision' => 12, 'scale' => 2, 'default' => '0.00', 'comment' => '余额'])
            ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '状态：0=禁用，1=启用'])
            ->addColumn('created_at', 'timestamp', ['null' => true])
            ->addColumn('updated_at', 'timestamp', ['null' => true])
            ->addIndex(['main_id'])
            ->addIndex(['card_no'], ['unique' => true])
            ->addIndex(['status'])
            ->create();
    }
} 